/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TDiscount;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TDiscountDao;
import com.ruipengkj.service.TDiscountService;
/**
 * 说明：
 * 资金出入表Service层接口实现
 * @Author：李智深
 * @Date：2012-03-16
 */
@Service
public class TDiscountServiceImpl implements TDiscountService{
	@Resource
	private TDiscountDao TDiscountDao;//DAO层
	
	//查询所有
	@Override
	public List<TDiscount> findService(TDiscount entity) throws Exception {
		String hql = "select o from TDiscount o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TDiscountDao.findDao(hql, whereHQL.toString(), param, orderby);
	}
	//根据ID翻页查询
	@Override
	public PageModel<TDiscount> getScrollService(int firstResult,
			int maxResult, TDiscount entity) throws Exception {
		String hql = "select o from TDiscount o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TDiscountDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}
	//修改
	@Override
	public void modifyService(TDiscount entity) throws Exception {
		TDiscountDao.modifyDao(entity);
		
	}
	//添加
	@Override
	public void saveService(TDiscount entity) throws Exception {
		TDiscountDao.saveDao(entity);
	}
	//根据ID删除
	@Override
	public void deleteService(String id) throws Exception {
		TDiscountDao.deleteDao(id);
		
	}
	//根据ID查询
	@Override
	public TDiscount getByIdService(String id) throws Exception {
		return TDiscountDao.getByIdDao(id);
	}
	//添加或修改
	@Override
	public void saveOrUpdateService(TDiscount entity) throws Exception {
		TDiscountDao.saveOrUpdateDao(entity);
	}
	//添加返回ID
	@Override
	public Serializable saveRetService(TDiscount entity) throws Exception {
		return TDiscountDao.saveRetDao(entity);
	}
	public TDiscountDao getTDiscountDao() {
		return TDiscountDao;
	}

	public void setTDiscountDao(TDiscountDao TDiscountDao) {
		this.TDiscountDao = TDiscountDao;
	}
}